import 'package:flutter/material.dart';
import 'dart:ui';

class OnlineStatus extends StatelessWidget {
  OnlineStatus({Key key, this.left, this.top, this.status = 'online'})
      : super(key: key) {
    left = 12;
    top = 12;
  }

  double left;
  double top;
  String status;

  bool get isOnline => status == 'online';
  bool get isOffline => status == 'ofline';
  bool get isBusy => status == 'busy';

  @override
  Widget build(BuildContext context) {
    return Positioned(
        left: left,
        top: top,
        child: Container(
            width: 64,
            height: 20,
            decoration: BoxDecoration(
                borderRadius: BorderRadius.all(Radius.circular(8)),
                color: const Color.fromRGBO(0, 0, 0, .3)),
            child: Row(mainAxisAlignment: MainAxisAlignment.center, children: [
              Container(
                width: 8,
                height: 8,
                margin: EdgeInsets.only(right: 3),
                decoration: BoxDecoration(
                    color: isOnline
                        ? const Color.fromRGBO(21, 240, 55, 1)
                        : isBusy
                            ? const Color.fromRGBO(242, 224, 16, 1)
                            : const Color.fromRGBO(242, 16, 79, 1),
                    borderRadius: BorderRadius.all(Radius.circular(4))),
              ),
              Text(
                  isOnline
                      ? 'Online'
                      : isBusy
                          ? 'Busy'
                          : 'Offline',
                  style: const TextStyle(color: Colors.white)),
            ])));
  }
}
